\(\int (a+b \tan (c+d \sqrt {x}))^2 \, dx\) [33]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [F]
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 16, antiderivative size = 119 \[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=a^2 x+2 i a b x-b^2 x-\frac {4 a b \sqrt {x} \log \left (1+e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d}+\frac {2 b^2 \log \left (\cos \left (c+d \sqrt {x}\right )\right )}{d^2}+\frac {2 i a b \operatorname {PolyLog}\left (2,-e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d^2}+\frac {2 b^2 \sqrt {x} \tan \left (c+d \sqrt {x}\right )}{d} \]

[Out]

a^2*x+2*I*a*b*x-b^2*x+2*b^2*ln(cos(c+d*x^(1/2)))/d^2+2*I*a*b*polylog(2,-exp(2*I*(c+d*x^(1/2))))/d^2-4*a*b*ln(1
+exp(2*I*(c+d*x^(1/2))))*x^(1/2)/d+2*b^2*x^(1/2)*tan(c+d*x^(1/2))/d

Rubi [A] (verified)

Time = 0.22 (sec) , antiderivative size = 119, normalized size of antiderivative = 1.00, number of steps used = 10, number of rules used = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.562, Rules used = {3824, 3803, 3800, 2221, 2317, 2438, 3801, 3556, 30} \[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=a^2 x+\frac {2 i a b \operatorname {PolyLog}\left (2,-e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d^2}-\frac {4 a b \sqrt {x} \log \left (1+e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d}+2 i a b x+\frac {2 b^2 \log \left (\cos \left (c+d \sqrt {x}\right )\right )}{d^2}+\frac {2 b^2 \sqrt {x} \tan \left (c+d \sqrt {x}\right )}{d}-b^2 x \]

[In]

Int[(a + b*Tan[c + d*Sqrt[x]])^2,x]

[Out]

a^2*x + (2*I)*a*b*x - b^2*x - (4*a*b*Sqrt[x]*Log[1 + E^((2*I)*(c + d*Sqrt[x]))])/d + (2*b^2*Log[Cos[c + d*Sqrt
[x]]])/d^2 + ((2*I)*a*b*PolyLog[2, -E^((2*I)*(c + d*Sqrt[x]))])/d^2 + (2*b^2*Sqrt[x]*Tan[c + d*Sqrt[x]])/d

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2221

Int[(((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)*((c_.) + (d_.)*(x_))^(m_.))/((a_) + (b_.)*((F_)^((g_.)*((e_.) +
 (f_.)*(x_))))^(n_.)), x_Symbol] :> Simp[((c + d*x)^m/(b*f*g*n*Log[F]))*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x]
 - Dist[d*(m/(b*f*g*n*Log[F])), Int[(c + d*x)^(m - 1)*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x], x] /; FreeQ[{F,
a, b, c, d, e, f, g, n}, x] && IGtQ[m, 0]

Rule 2317

Int[Log[(a_) + (b_.)*((F_)^((e_.)*((c_.) + (d_.)*(x_))))^(n_.)], x_Symbol] :> Dist[1/(d*e*n*Log[F]), Subst[Int
[Log[a + b*x]/x, x], x, (F^(e*(c + d*x)))^n], x] /; FreeQ[{F, a, b, c, d, e, n}, x] && GtQ[a, 0]

Rule 2438

Int[Log[(c_.)*((d_) + (e_.)*(x_)^(n_.))]/(x_), x_Symbol] :> Simp[-PolyLog[2, (-c)*e*x^n]/n, x] /; FreeQ[{c, d,
 e, n}, x] && EqQ[c*d, 1]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3800

Int[((c_.) + (d_.)*(x_))^(m_.)*tan[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[I*((c + d*x)^(m + 1)/(d*(m + 1))), x
] - Dist[2*I, Int[(c + d*x)^m*(E^(2*I*(e + f*x))/(1 + E^(2*I*(e + f*x)))), x], x] /; FreeQ[{c, d, e, f}, x] &&
 IGtQ[m, 0]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rule 3803

Int[((c_.) + (d_.)*(x_))^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Int[ExpandIntegrand[
(c + d*x)^m, (a + b*Tan[e + f*x])^n, x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && IGtQ[m, 0] && IGtQ[n, 0]

Rule 3824

Int[((a_.) + (b_.)*Tan[(c_.) + (d_.)*(x_)^(n_)])^(p_.), x_Symbol] :> Dist[1/n, Subst[Int[x^(1/n - 1)*(a + b*Ta
n[c + d*x])^p, x], x, x^n], x] /; FreeQ[{a, b, c, d, p}, x] && IGtQ[1/n, 0] && IntegerQ[p]

Rubi steps \begin{align*} \text {integral}& = 2 \text {Subst}\left (\int x (a+b \tan (c+d x))^2 \, dx,x,\sqrt {x}\right ) \\ & = 2 \text {Subst}\left (\int \left (a^2 x+2 a b x \tan (c+d x)+b^2 x \tan ^2(c+d x)\right ) \, dx,x,\sqrt {x}\right ) \\ & = a^2 x+(4 a b) \text {Subst}\left (\int x \tan (c+d x) \, dx,x,\sqrt {x}\right )+\left (2 b^2\right ) \text {Subst}\left (\int x \tan ^2(c+d x) \, dx,x,\sqrt {x}\right ) \\ & = a^2 x+2 i a b x+\frac {2 b^2 \sqrt {x} \tan \left (c+d \sqrt {x}\right )}{d}-(8 i a b) \text {Subst}\left (\int \frac {e^{2 i (c+d x)} x}{1+e^{2 i (c+d x)}} \, dx,x,\sqrt {x}\right )-\left (2 b^2\right ) \text {Subst}\left (\int x \, dx,x,\sqrt {x}\right )-\frac {\left (2 b^2\right ) \text {Subst}\left (\int \tan (c+d x) \, dx,x,\sqrt {x}\right )}{d} \\ & = a^2 x+2 i a b x-b^2 x-\frac {4 a b \sqrt {x} \log \left (1+e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d}+\frac {2 b^2 \log \left (\cos \left (c+d \sqrt {x}\right )\right )}{d^2}+\frac {2 b^2 \sqrt {x} \tan \left (c+d \sqrt {x}\right )}{d}+\frac {(4 a b) \text {Subst}\left (\int \log \left (1+e^{2 i (c+d x)}\right ) \, dx,x,\sqrt {x}\right )}{d} \\ & = a^2 x+2 i a b x-b^2 x-\frac {4 a b \sqrt {x} \log \left (1+e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d}+\frac {2 b^2 \log \left (\cos \left (c+d \sqrt {x}\right )\right )}{d^2}+\frac {2 b^2 \sqrt {x} \tan \left (c+d \sqrt {x}\right )}{d}-\frac {(2 i a b) \text {Subst}\left (\int \frac {\log (1+x)}{x} \, dx,x,e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d^2} \\ & = a^2 x+2 i a b x-b^2 x-\frac {4 a b \sqrt {x} \log \left (1+e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d}+\frac {2 b^2 \log \left (\cos \left (c+d \sqrt {x}\right )\right )}{d^2}+\frac {2 i a b \operatorname {PolyLog}\left (2,-e^{2 i \left (c+d \sqrt {x}\right )}\right )}{d^2}+\frac {2 b^2 \sqrt {x} \tan \left (c+d \sqrt {x}\right )}{d} \\ \end{align*}

Mathematica [B] (verified)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(253\) vs. \(2(119)=238\).

Time = 4.95 (sec) , antiderivative size = 253, normalized size of antiderivative = 2.13 \[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=\frac {\sec (c) \left (-2 a b \cos (c) \left (i d \sqrt {x} (\pi +2 \arctan (\cot (c)))+\pi \log \left (1+e^{-2 i d \sqrt {x}}\right )+2 \left (d \sqrt {x}-\arctan (\cot (c))\right ) \log \left (1-e^{2 i \left (d \sqrt {x}-\arctan (\cot (c))\right )}\right )-\pi \log \left (\cos \left (d \sqrt {x}\right )\right )+2 \arctan (\cot (c)) \log \left (\sin \left (d \sqrt {x}-\arctan (\cot (c))\right )\right )-i \operatorname {PolyLog}\left (2,e^{2 i \left (d \sqrt {x}-\arctan (\cot (c))\right )}\right )\right )-2 a b d^2 e^{-i \arctan (\cot (c))} x \sqrt {\csc ^2(c)} \sin (c)+d^2 x \left (\left (a^2-b^2\right ) \cos (c)+2 a b \sin (c)\right )+2 b^2 \left (\cos (c) \log \left (\cos \left (c+d \sqrt {x}\right )\right )+d \sqrt {x} \sin (c)\right )+2 b^2 d \sqrt {x} \sec \left (c+d \sqrt {x}\right ) \sin \left (d \sqrt {x}\right )\right )}{d^2} \]

[In]

Integrate[(a + b*Tan[c + d*Sqrt[x]])^2,x]

[Out]

(Sec[c]*(-2*a*b*Cos[c]*(I*d*Sqrt[x]*(Pi + 2*ArcTan[Cot[c]]) + Pi*Log[1 + E^((-2*I)*d*Sqrt[x])] + 2*(d*Sqrt[x]
- ArcTan[Cot[c]])*Log[1 - E^((2*I)*(d*Sqrt[x] - ArcTan[Cot[c]]))] - Pi*Log[Cos[d*Sqrt[x]]] + 2*ArcTan[Cot[c]]*
Log[Sin[d*Sqrt[x] - ArcTan[Cot[c]]]] - I*PolyLog[2, E^((2*I)*(d*Sqrt[x] - ArcTan[Cot[c]]))]) - (2*a*b*d^2*x*Sq
rt[Csc[c]^2]*Sin[c])/E^(I*ArcTan[Cot[c]]) + d^2*x*((a^2 - b^2)*Cos[c] + 2*a*b*Sin[c]) + 2*b^2*(Cos[c]*Log[Cos[
c + d*Sqrt[x]]] + d*Sqrt[x]*Sin[c]) + 2*b^2*d*Sqrt[x]*Sec[c + d*Sqrt[x]]*Sin[d*Sqrt[x]]))/d^2

Maple [F]

\[\int \left (a +b \tan \left (c +d \sqrt {x}\right )\right )^{2}d x\]

[In]

int((a+b*tan(c+d*x^(1/2)))^2,x)

[Out]

int((a+b*tan(c+d*x^(1/2)))^2,x)

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 196, normalized size of antiderivative = 1.65 \[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=\frac {2 \, b^{2} d \sqrt {x} \tan \left (d \sqrt {x} + c\right ) + {\left (a^{2} - b^{2}\right )} d^{2} x - i \, a b {\rm Li}_2\left (\frac {2 \, {\left (i \, \tan \left (d \sqrt {x} + c\right ) - 1\right )}}{\tan \left (d \sqrt {x} + c\right )^{2} + 1} + 1\right ) + i \, a b {\rm Li}_2\left (\frac {2 \, {\left (-i \, \tan \left (d \sqrt {x} + c\right ) - 1\right )}}{\tan \left (d \sqrt {x} + c\right )^{2} + 1} + 1\right ) - {\left (2 \, a b d \sqrt {x} - b^{2}\right )} \log \left (-\frac {2 \, {\left (i \, \tan \left (d \sqrt {x} + c\right ) - 1\right )}}{\tan \left (d \sqrt {x} + c\right )^{2} + 1}\right ) - {\left (2 \, a b d \sqrt {x} - b^{2}\right )} \log \left (-\frac {2 \, {\left (-i \, \tan \left (d \sqrt {x} + c\right ) - 1\right )}}{\tan \left (d \sqrt {x} + c\right )^{2} + 1}\right )}{d^{2}} \]

[In]

integrate((a+b*tan(c+d*x^(1/2)))^2,x, algorithm="fricas")

[Out]

(2*b^2*d*sqrt(x)*tan(d*sqrt(x) + c) + (a^2 - b^2)*d^2*x - I*a*b*dilog(2*(I*tan(d*sqrt(x) + c) - 1)/(tan(d*sqrt
(x) + c)^2 + 1) + 1) + I*a*b*dilog(2*(-I*tan(d*sqrt(x) + c) - 1)/(tan(d*sqrt(x) + c)^2 + 1) + 1) - (2*a*b*d*sq
rt(x) - b^2)*log(-2*(I*tan(d*sqrt(x) + c) - 1)/(tan(d*sqrt(x) + c)^2 + 1)) - (2*a*b*d*sqrt(x) - b^2)*log(-2*(-
I*tan(d*sqrt(x) + c) - 1)/(tan(d*sqrt(x) + c)^2 + 1)))/d^2

Sympy [F]

\[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=\int \left (a + b \tan {\left (c + d \sqrt {x} \right )}\right )^{2}\, dx \]

[In]

integrate((a+b*tan(c+d*x**(1/2)))**2,x)

[Out]

Integral((a + b*tan(c + d*sqrt(x)))**2, x)

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 497 vs. \(2 (98) = 196\).

Time = 0.54 (sec) , antiderivative size = 497, normalized size of antiderivative = 4.18 \[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=a^{2} x + \frac {4 \, b^{2} d \sqrt {x} + 4 \, {\left (a b \cos \left (2 \, d \sqrt {x} + 2 \, c\right ) + i \, a b \sin \left (2 \, d \sqrt {x} + 2 \, c\right ) + a b\right )} \arctan \left (\sin \left (2 \, d \sqrt {x} - 2 \, c\right ), \cos \left (2 \, d \sqrt {x} - 2 \, c\right ) + 1\right ) \arctan \left (\sin \left (d \sqrt {x}\right ), \cos \left (d \sqrt {x}\right )\right ) - 2 \, {\left (i \, a b \cos \left (2 \, d \sqrt {x} + 2 \, c\right ) - a b \sin \left (2 \, d \sqrt {x} + 2 \, c\right ) + i \, a b\right )} \arctan \left (\sin \left (d \sqrt {x}\right ), \cos \left (d \sqrt {x}\right )\right ) \log \left (\cos \left (2 \, d \sqrt {x} - 2 \, c\right )^{2} + \sin \left (2 \, d \sqrt {x} - 2 \, c\right )^{2} + 2 \, \cos \left (2 \, d \sqrt {x} - 2 \, c\right ) + 1\right ) - {\left ({\left (2 \, a b - i \, b^{2}\right )} d^{2} \cos \left (2 \, d \sqrt {x} + 2 \, c\right ) - {\left (-2 i \, a b - b^{2}\right )} d^{2} \sin \left (2 \, d \sqrt {x} + 2 \, c\right ) + {\left (2 \, a b - i \, b^{2}\right )} d^{2}\right )} x + 2 \, {\left (b^{2} \cos \left (2 \, d \sqrt {x} + 2 \, c\right ) + i \, b^{2} \sin \left (2 \, d \sqrt {x} + 2 \, c\right ) + b^{2}\right )} \arctan \left (\sin \left (2 \, d \sqrt {x}\right ) + \sin \left (2 \, c\right ), \cos \left (2 \, d \sqrt {x}\right ) + \cos \left (2 \, c\right )\right ) - 2 \, {\left (a b \cos \left (2 \, d \sqrt {x} + 2 \, c\right ) + i \, a b \sin \left (2 \, d \sqrt {x} + 2 \, c\right ) + a b\right )} {\rm Li}_2\left (-e^{\left (2 i \, d \sqrt {x} - 2 i \, c\right )}\right ) + {\left (-i \, b^{2} \cos \left (2 \, d \sqrt {x} + 2 \, c\right ) + b^{2} \sin \left (2 \, d \sqrt {x} + 2 \, c\right ) - i \, b^{2}\right )} \log \left (\cos \left (2 \, d \sqrt {x}\right )^{2} + 2 \, \cos \left (2 \, d \sqrt {x}\right ) \cos \left (2 \, c\right ) + \cos \left (2 \, c\right )^{2} + \sin \left (2 \, d \sqrt {x}\right )^{2} + 2 \, \sin \left (2 \, d \sqrt {x}\right ) \sin \left (2 \, c\right ) + \sin \left (2 \, c\right )^{2}\right )}{-i \, d^{2} \cos \left (2 \, d \sqrt {x} + 2 \, c\right ) + d^{2} \sin \left (2 \, d \sqrt {x} + 2 \, c\right ) - i \, d^{2}} \]

[In]

integrate((a+b*tan(c+d*x^(1/2)))^2,x, algorithm="maxima")

[Out]

a^2*x + (4*b^2*d*sqrt(x) + 4*(a*b*cos(2*d*sqrt(x) + 2*c) + I*a*b*sin(2*d*sqrt(x) + 2*c) + a*b)*arctan2(sin(2*d
*sqrt(x) - 2*c), cos(2*d*sqrt(x) - 2*c) + 1)*arctan2(sin(d*sqrt(x)), cos(d*sqrt(x))) - 2*(I*a*b*cos(2*d*sqrt(x
) + 2*c) - a*b*sin(2*d*sqrt(x) + 2*c) + I*a*b)*arctan2(sin(d*sqrt(x)), cos(d*sqrt(x)))*log(cos(2*d*sqrt(x) - 2
*c)^2 + sin(2*d*sqrt(x) - 2*c)^2 + 2*cos(2*d*sqrt(x) - 2*c) + 1) - ((2*a*b - I*b^2)*d^2*cos(2*d*sqrt(x) + 2*c)
 - (-2*I*a*b - b^2)*d^2*sin(2*d*sqrt(x) + 2*c) + (2*a*b - I*b^2)*d^2)*x + 2*(b^2*cos(2*d*sqrt(x) + 2*c) + I*b^
2*sin(2*d*sqrt(x) + 2*c) + b^2)*arctan2(sin(2*d*sqrt(x)) + sin(2*c), cos(2*d*sqrt(x)) + cos(2*c)) - 2*(a*b*cos
(2*d*sqrt(x) + 2*c) + I*a*b*sin(2*d*sqrt(x) + 2*c) + a*b)*dilog(-e^(2*I*d*sqrt(x) - 2*I*c)) + (-I*b^2*cos(2*d*
sqrt(x) + 2*c) + b^2*sin(2*d*sqrt(x) + 2*c) - I*b^2)*log(cos(2*d*sqrt(x))^2 + 2*cos(2*d*sqrt(x))*cos(2*c) + co
s(2*c)^2 + sin(2*d*sqrt(x))^2 + 2*sin(2*d*sqrt(x))*sin(2*c) + sin(2*c)^2))/(-I*d^2*cos(2*d*sqrt(x) + 2*c) + d^
2*sin(2*d*sqrt(x) + 2*c) - I*d^2)

Giac [F]

\[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=\int { {\left (b \tan \left (d \sqrt {x} + c\right ) + a\right )}^{2} \,d x } \]

[In]

integrate((a+b*tan(c+d*x^(1/2)))^2,x, algorithm="giac")

[Out]

integrate((b*tan(d*sqrt(x) + c) + a)^2, x)

Mupad [F(-1)]

Timed out. \[ \int \left (a+b \tan \left (c+d \sqrt {x}\right )\right )^2 \, dx=\int {\left (a+b\,\mathrm {tan}\left (c+d\,\sqrt {x}\right )\right )}^2 \,d x \]

[In]

int((a + b*tan(c + d*x^(1/2)))^2,x)

[Out]

int((a + b*tan(c + d*x^(1/2)))^2, x)